import 'package:get_storage/get_storage.dart';

class LocalStorage {
  final GetStorage getStorage = GetStorage();
  static const prefix = "storage.";

  static LocalStorage get instance {
    return LocalStorage();
  }

  /// 获取缓存数据
  T? getItem<T>(String key) {
    return getStorage.read(prefix + key);
  }

  /// 写入缓存数据
  setItem(String key, dynamic value) {
    getStorage.write(prefix + key, value);
  }

  /// 删除缓存数据
  removeItem(String key) {
    getStorage.remove(prefix + key);
  }
}
